package net.alteiar.ui;

import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import net.alteiar.images.IDrawable;
import net.alteiar.images.metadata.EntityInfo;

public class VisionImagePanel<E extends IDrawable> extends ZoomablePanel<E> {
	private static final long serialVersionUID = 1L;

	// private final VisionImageFilter visionFilter;
	private final EntityInfo entity;

	public VisionImagePanel(E img, EntityInfo entity) {
		// VisionImageFilter image) {
		super(img);
		this.entity = entity;
		// visionFilter = image;

		this.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				move(e.getPoint());
			}
		});
	}

	private void move(Point target) {
		Point center = panelToImage(target);
		int squareSize = 30;
		center.x = (int) (Math.floor(center.x / squareSize) * squareSize);
		center.y = (int) (Math.floor((center.y / squareSize)) * squareSize);

		this.entity.setCenter(center);
		// visionFilter.setCenter(panelToImage(target));
	}
}
